package org.structure.boot.demomybatis.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.structure.boot.demomybatis.entity.User;
import org.structure.boot.demomybatis.mapper.UserMapper;
import org.structure.boot.demomybatis.service.IUserService;
import org.structure.boot.demomybatis.utils.IdUtil;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @version V1.0.0
 * @Title: UserServiceImpl
 * @Package org.structure.boot.demomybatis.service.impl
 * @Description: 用户service
 * @author: chuck
 * @date: 2020/6/1 11:11
 */
@Slf4j
@Service
public class UserServiceImpl implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public String addUser(User user) {
        String id = IdUtil.getUUID();
        user.setId(id);
        user.setCreateTime(new Date());
        userMapper.save(user);
        return id;
    }

    @Override
    public User findById(String id) {
        return userMapper.findById(id);
    }
}
